package com.master.demo.example.funcation;

/**
 * 说明
 *
 * @author: Yang
 * @date: 2022/1/7
 * @version: 1.0.0
 * Copyright Ⓒ 2021 恒翔 Computer Corporation Limited All rights reserved.
 */
public class BranchHandleExample {

    public static void main(String[] args) {
        isTureOrFalse(true).trueOrFalseHandle(() -> {
            System.out.println("true");
        }, () -> {
            System.out.println("false");
        });
    }


    /**
     * 参数为true或false时，分别进行不同的操作
     *
     * @param b
     * @return com.example.demo.func.BranchHandle
     **/
    public static BranchHandle isTureOrFalse(boolean b) {

        return (trueHandle, falseHandle) -> {
            if (b) {
                trueHandle.run();
            } else {
                falseHandle.run();
            }
        };
    }

}
